#include <sstream>
#include <iomanip>
#include <opencv2/dnn.hpp>

#include "base_util/utils.h"
#include "rec_predictor.h"


namespace ai {


TRTOcrRecPredictor::TRTOcrRecPredictor(TRTPackPredictor* model, TRTModelManager* manager, LogInfo *lg):
  TRTPredictor(model, manager, lg) { }


int TRTOcrRecPredictor::RunDet(stream::ImageBlob* blob, std::vector<BaseInfo*>& det_infos) {
  int ret = 0;

  stream::ImageBlob img_blob(stream::ImageBlobMode_BGR);
  if (!mdl_trt->cfg->transforms->run(blob->img, img_blob, mdl_trt->cfg)) { 
    printf("transforms->run fail \n");
    return model_image_channels_check_error;
  }
  std::cout << img_blob.img.cols << ", " << img_blob.img.rows << ", c:" << img_blob.img.channels() << std::endl;
  // std::cout << "img_blob.scale: " << img_blob.scale << std::endl;
  // img_blob.img.convertTo(img_blob.img, CV_32FC(img_blob.img.channels()));
  // std::cout << img_blob.img.type() << std::endl;
  
  if (mdl_trt->cfg->arch == "CRNN.plate") {
    // GetConvDetectionResult(img_blob, det_infos);
  } else {
    spdlog::get("logger")->info("ERROR. TRTDetPredictor::RunDet. mdl_trt->cfg->arch error: {} ", mdl_trt->cfg->arch);
  }



  // std::cout << " NMSBoxes:" << det_infos.size() << std::endl;
  return 0;
}

int TRTOcrRecPredictor::GetConvDetectionResult(stream::ImageBlob& img_blob, std::vector<BaseInfo*>& rec_infos) {
  int ret = 0;

  return ret;
}


}  // namespace ai
